import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:tiktokadult/assets_tool/app_colors.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/config/address.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';

import 'mine_identity_logic.dart';

//账号凭证页面
class MineAccountIdentityPage extends StatelessWidget {
  const MineAccountIdentityPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MineIdentityLogic>(
      init: MineIdentityLogic(),
      builder: (controller) {
        return Scaffold(
          extendBodyBehindAppBar: false,
          appBar: AppBar(title: Text('账号凭证')),
          body: Padding(
            padding: EdgeInsets.only(left: 0, top: 5, right: 0),
            child: Column(
              children: [
                Expanded(
                  child: Stack(
                    children: [
                      RepaintBoundary(
                        key: controller.boundaryKey,
                        child: Stack(
                          alignment: Alignment.bottomCenter,
                          children: [
                            ClipRRect(
                              borderRadius: BorderRadius.circular(9),
                              child: Image.asset('account_certificate_bg.webp'.mineImgPath,
                                width: double.infinity,
                                fit: BoxFit.fitWidth,
                              ),
                            ),
                            Positioned.fill(
                              child: Container(
                                decoration: BoxDecoration(
                                  gradient: LinearGradient(
                                    colors: [
                                      Colors.transparent,
                                      Color(0xff151515),
                                    ],
                                    begin: Alignment.topCenter,
                                    end: Alignment.bottomCenter,
                                  ),
                                ),
                              ),
                            ),
                            Positioned.fill(
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.end,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Center(
                                    child: Container(
                                      padding: EdgeInsets.all(11.w),
                                      decoration: BoxDecoration(
                                        image: DecorationImage(
                                          image: AssetImage("code_bg.png".mineImgPath),
                                          fit: BoxFit.fill,
                                        ),
                                      ),
                                      child: Container(
                                          padding: EdgeInsets.all(6.w),
                                          color: Colors.white,
                                          child: controller.qrCodeStr.isNotEmpty
                                              ? QrImageView(
                                                  data: controller.qrCodeStr,
                                                  version: QrVersions.auto,
                                                  padding: EdgeInsets.zero,
                                                  size: 164.w,
                                                )
                                              : SizedBox.shrink()),
                                    ),
                                  ),
                                  18.h.sizeBoxH,
                                  Text(
                                    '账号凭证',
                                    style: TextStyle(
                                      color: Colors.white,
                                      fontSize: 20.sp,
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  6.h.sizeBoxH,
                                  Text(
                                    'ID ${controller.meInfo?.uid ?? 0}',
                                    style: textStyle(36, Colors.white.withOpacity(.9), FontWeight.w500),
                                  ),
                                  6.sizeBoxH,
                                  Container(
                                    height: 30,
                                    padding: EdgeInsets.symmetric(horizontal: 18, vertical: 3),
                                    decoration: BoxDecoration(
                                      color: Colors.black.withOpacity(.3),
                                      borderRadius: BorderRadius.circular(30),
                                    ),
                                    child: Text(
                                      'tiktokadult 官网地址 ${Address.groundURl ?? ""}',
                                      style: TextStyle(
                                        color: Colors.white.withOpacity(.9),
                                        fontSize: 14,
                                        fontWeight: FontWeight.w400,
                                      ),
                                    ),
                                  ),
                                  4.sizeBoxH,
                                  Text(
                                    '提示*可通过官方客服找回账号',
                                    style: TextStyle(
                                      color: AppColors.actionRed,
                                      fontSize: 12,
                                      fontWeight: FontWeight.w400,
                                    ),
                                  ),
                                  44.h.sizeBoxH,
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
                15.sizeBoxH,
                InkWell(
                  onTap: () {
                    controller.saveImage(context);
                  },
                  child: Container(
                    height: 44,
                    margin: EdgeInsets.symmetric(horizontal: 30),
                    decoration: BoxDecoration(
                      color: AppColors.actionRed,
                      borderRadius: BorderRadius.circular(3),
                    ),
                    alignment: Alignment.center,
                    child: Text(
                      "保存图片",
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 16,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ),
                ),
                15.sizeBoxH,
              ],
            ),
          ),
        );
      },
    );
  }
}
